/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.hl7.datatypes.r2.foundation;

import java.io.Serializable;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.MappedSuperclass;
import org.hl7.datatypes.r2.basic.CS;
import org.hl7.datatypes.r2.basic.UID;
import org.hl7.datatypes.r2.constant.NullFlavor;
import org.hl7.datatypes.r2.flavors.bl.BN;
import org.hl7.datatypes.r2.flavors.st.ST_NT;
import org.hl7.datatypes.r2.flavors.st.ST_SIMPLE;

/**
 *
 * @author Obama
 */
@Embeddable
public class ANY implements Serializable {

    @Embedded
    private TYPE dataType;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE"))
    private ST_SIMPLE nullFlavorCode;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE_SYSTEM"))
    private UID nullFlavorCodeSystem;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE_SYSTEM_NAME"))
    private ST_NT nullFlavorCodeSystemName;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE_SYSTEM_VERSION"))
    private ST_SIMPLE nullFlavorCodeSystemVersion;

    public TYPE dataType() {
        return dataType;
    }

    public CS nullFlavor() {
        return new CS(nullFlavorCode, nullFlavorCodeSystem, nullFlavorCodeSystemName, nullFlavorCodeSystemVersion);
    }

    public BN nonNull() {
        return new BN(!nonNull().getBooleanValue().booleanValue());
    }

    public BN isNull() {
        return new BN(nullFlavor() != null && !nullFlavor().getNullFlavorCode().isNull().getBooleanValue().booleanValue());
    }

    public BL notApplicable() {
        return nullFlavor().equal(NullFlavor.NA.cs());
    }

    public BL unknown() {
        return nullFlavor().equal(NullFlavor.UNK.cs());
    }

    public BL other() {
        return nullFlavor().equal(NullFlavor.OTH.cs());
    }

    public BL equal(ANY x) {
        return new BL(this.equals(x));
    }

    protected BN identical(ANY x) {
        return null;
    }

    public TYPE getDataType() {
        return dataType;
    }

    public void setDataType(TYPE dataType) {
        this.dataType = dataType;
    }

    public ST_SIMPLE getNullFlavorCode() {
        return nullFlavorCode;
    }

    public void setNullFlavorCode(ST_SIMPLE nullFlavorCode) {
        this.nullFlavorCode = nullFlavorCode;
    }

    public UID getNullFlavorCodeSystem() {
        return nullFlavorCodeSystem;
    }

    public void setNullFlavorCodeSystem(UID nullFlavorCodeSystem) {
        this.nullFlavorCodeSystem = nullFlavorCodeSystem;
    }

    public ST_NT getNullFlavorCodeSystemName() {
        return nullFlavorCodeSystemName;
    }

    public void setNullFlavorCodeSystemName(ST_NT nullFlavorCodeSystemName) {
        this.nullFlavorCodeSystemName = nullFlavorCodeSystemName;
    }

    public ST_SIMPLE getNullFlavorCodeSystemVersion() {
        return nullFlavorCodeSystemVersion;
    }

    public void setNullFlavorCodeSystemVersion(ST_SIMPLE nullFlavorCodeSystemVersion) {
        this.nullFlavorCodeSystemVersion = nullFlavorCodeSystemVersion;
    }

    
    
}
